package com.voxel.sense.infomsg.module.firm.details.institution.data;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentPagerAdapter;
import android.support.v4.view.ViewPager;

import com.example.com.common.app.BaseActivity;
import com.flyco.tablayout.SlidingTabLayout;
import com.voxel.sense.infomsg.R;
import com.voxel.sense.infomsg.module.common.SlidingTabPageAdapter;
import com.voxel.sense.infomsg.module.firm.details.average.DataAverageFrag;
import com.voxel.sense.infomsg.module.firm.details.chars.SourceCharDataFrag;
import com.voxel.sense.infomsg.module.firm.details.history.HistoryDataFrag;
import com.voxel.sense.infomsg.view.titlebar.TextTitleBar;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import cyy.example.com.facotry.constants.IntentConstants;


/**
 * 站位数据
 */

public class InstitutionDataActivity extends BaseActivity {
    @BindView(R.id.stl_tip)
    SlidingTabLayout stl_tip;
    @BindView(R.id.vp_content)
    ViewPager vp_content;
    @BindView(R.id.titlebar)
    TextTitleBar titlebar;

    private String mId;

    public static void show(Context context, String id) {
        Intent intent = new Intent(context, InstitutionDataActivity.class);
        intent.putExtra(IntentConstants.STRING_TYPE, id);
        context.startActivity(intent);
    }


    @Override
    protected int getContentLayoutId() {
        return R.layout.activity_institution_data;
    }

    @Override
    protected boolean initArgs(Bundle bundle) {
        mId = bundle.getString(IntentConstants.STRING_TYPE);
        return super.initArgs(bundle);
    }

    @Override
    protected void initData() {
        super.initData();
        String[] mTitle = {"实时数据", "历史数据", "平均值"};
        Bundle bundle = new Bundle();
        bundle.putString("name", "");
        bundle.putString(IntentConstants.STRING_TYPE, mId);
        List datas = new ArrayList();
        datas.add(Fragment.instantiate(this, SourceCharDataFrag.class.getName(), bundle));
        datas.add(Fragment.instantiate(this, HistoryDataFrag.class.getName(), bundle));
        datas.add(Fragment.instantiate(this, DataAverageFrag.class.getName(), bundle));
        FragmentPagerAdapter adpter = new SlidingTabPageAdapter(getSupportFragmentManager(), datas, mTitle);

        vp_content.setAdapter(adpter);
        vp_content.setOffscreenPageLimit(2);
        stl_tip.setViewPager(vp_content);
        titlebar.setTitleText("企业数据");
    }


}
